package com.ls.fw.data.service;

import java.sql.SQLException;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.ls.fw.data.bean.Record;
import com.ls.fw.data.bean.Table;
import com.ls.fw.data.dao.DaoAdapter;
import com.ls.fw.data.mapper.RowMapper;
import com.ls.fw.data.mapper.ScanRowMapper;
import com.ls.fw.data.result.DataResult;
import com.ls.fw.data.result.DataResultSet;
import com.ls.fw.data.statement.Delete;
import com.ls.fw.data.statement.Insert;
import com.ls.fw.data.statement.Select;
import com.ls.fw.data.statement.Update;

public abstract class DataServiceAdapter extends DaoAdapter implements DataService{
	
	protected Logger logger = LoggerFactory.getLogger(this.getClass());


	@Override
	public boolean insert(Insert insert, boolean checkExist) {
		return this.getDao().insert(insert, checkExist);
	}

	@Override
	public boolean delete(Delete delete) {
		return this.getDao().delete(delete);
	}

	@Override
	public boolean update(Update update, boolean checkExist) {
		return this.getDao().update(update, checkExist);
	}

	@Override
	public DataResult search(Select select) {
		return this.getDao().search(select);
	}

	@Override
	public DataResultSet executeQuery(Select select) {
		return this.getDao().executeQuery(select);
	}

	@Override
	public long executeQueryForInt(Select select) throws SQLException {
		return this.getDao().executeQueryForInt(select);
	}

	@Override
	public void execute(String sql, boolean checkExist) {
		this.getDao().execute(sql, checkExist);
	}

	@Override
	public long executeQueryForInt(String sql) throws SQLException {
		return this.getDao().executeQueryForInt(sql);
	}

	@Override
	public List<?> executeQuery(String sql) {
		return this.getDao().executeQuery(sql);
	}


	@Override
	public <T> long scan(Select select, ScanRowMapper<T> rowMapper)
			throws SQLException {
		return this.getDao().scan(select, rowMapper);
	}

	@Override
	public <T> List<T> search(Select select, RowMapper<T> rowMapper) {
		return this.getDao().search(select, rowMapper);
	}


	@Override
	public void execute(String sql) {
		this.getDao().execute(sql);
	}


	@Override
	public long load(Table fromTable, Select select, Table toTable,
			boolean deleteOldData, ScanRowMapper<Record> rowMapper)
			throws SQLException {
		return this.getDao().load(fromTable, select, toTable, deleteOldData, rowMapper);
	}
}
